package org.example.api.admin;

import org.example.R.R;
import org.example.entity.dto.AddAddressBookDto;
import org.example.service.AddressBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 通讯录
 */

@RestController
@RequestMapping("/api/admin/address_book")
public class AddressBookController {

    @Autowired
    private AddressBookService addressBookService;

    @PostMapping("/add")
    public R add(@Valid @RequestBody AddAddressBookDto dto) {
        return addressBookService.add(dto);
    }

    @PostMapping("/delete")
    public R delete(@RequestParam("id") Long id) {
        return addressBookService.delete(id);
    }

    @PostMapping("/detail")
    public R detail(@RequestParam("id") Long id){
        return addressBookService.detail(id);
    }

    @PostMapping("/list")
    public R list() {
        return addressBookService.list();
    }


}
